package com.amos.base.wrapper;

/**
 * @author Amos
 * @ClassName ResponseWrapper
 * @Description 接口请求返回的封装类
 * @Date 2018/12/6 21:10
 * @VERSION 1.0
 **/
public class ResponseWrapper {
    /**
     * 返回正确的结果，并且返回信息
     * @param msg
     * @return
     */
    public static Result OK(String msg){
       return new Result.Builder(Result.RESULT_SUCCESS).msg(msg).builder();
    }

    /**
     * 返回正确的结果
     * @return
     */
    public static Result OK(){
        return new Result.Builder(Result.RESULT_SUCCESS).msg(Result.DEFAULT_MSG).builder();
    }

    /**
     * 返回正确的结果，并且返回数据
     * @param data
     * @return
     */
    public static Result OK (Object data){
        return new Result.Builder(Result.RESULT_SUCCESS).msg(Result.DEFAULT_MSG).data(data).builder();
    }

    /**
     * 业务验证失败，返回失败的原因
     * @param msg
     * @return
     */
    public static Result FAIL(String msg){
        return new Result.Builder(Result.RESULT_VALIDATEERROR).msg(msg).builder();
    }

    /**
     * 业务验证失败
     * @return
     */
    public static Result FAIL(){

        return new Result.Builder(Result.RESULT_VALIDATEERROR).builder();
    }

    /**
     * 业务异常
     * @return
     */
    public static Result ERROR(){
        return new Result.Builder(Result.RESULT_ERROR).msg(Result.DEFAULT_ERROR).builder();
    }

    /**
     * 异常出现异常，并且返回异常的信息
     * @param msg
     * @return
     */
    public static Result ERROR(String msg){
        return new Result.Builder(Result.RESULT_ERROR).msg(msg).builder();
    }

}
